Skip to content

feat: Agent Profile 全局配置体系(Phase 1-2)#249

Open
SheldonLiu0412 wants to merge 1 commit intoErlichLiu:mainfrom
SheldonLiu0412:feat/agent-profile-phase1
Open

feat: Agent Profile 全局配置体系(Phase 1-2)#249
SheldonLiu0412 wants to merge 1 commit intoErlichLiu:mainfrom
SheldonLiu0412:feat/agent-profile-phase1

Conversation

@SheldonLiu0412
Copy link
Copy Markdown
Contributor

@SheldonLiu0412 SheldonLiu0412 commented Apr 12, 2026

Agent 角色

Agent 模式独立的角色配置体系,实现按角色精确分配能力和任务:

  • 由角色决定 MCP/Skills/Model 等详细配置,工作区只管理 Seesion/File
  • 设置页新增「Agents」进行角色配置

具体修改

数据层(4 文件)

  • packages/shared/src/types/agent.ts — 新增 AgentProfile 类型定义、IPC 通道常量、CRUD 输入类型
  • apps/electron/src/main/lib/agent-profile-service.ts新文件,AgentProfile CRUD + 预置通用助手初始化
  • apps/electron/src/main/lib/config-paths.ts — 新增 getAgentProfilePluginDir(含 UUID 格式校验)
  • apps/electron/src/main/ipc.ts — 注册 Agent Profile 的 5 个 IPC handler + LIST_ALL_CAPABILITIES

编排层(1 文件)

  • apps/electron/src/main/lib/agent-orchestrator.ts
    • buildProfileMcpServers() — 按 Profile 精确加载 MCP 服务器
    • buildProfilePluginDir() — 基于 symlink 的 Skill 精确过滤 + 缓存复用 + 并发锁
    • 配置优先级调整:会话输入 > Agent Profile > 全局默认
    • 动态 import 改为静态 import,inline import type 提升至顶层

渲染层(10 文件)

  • AgentSelector.tsx新文件,会话输入框的 Agent 选择器组件
  • AgentView.tsx — 集成 per-session profile/channel/model map,pendingPrompt 同步
  • QuickTaskApp.tsx — @ mention 触发弹窗(mirror div 精确定位、键盘导航、内联 mention 标签)
  • AgentProfileSettings.tsx新文件,设置页 Agents 列表(骨架屏、能力 badge、builtin 标识)
  • AgentProfileForm.tsx新文件,Agent 编辑表单(emoji picker、chip 能力选择、折叠高级选项)
  • SettingsPanel.tsx — Agent 模式下注册 Agents Tab
  • GlobalShortcuts.tsx — QuickTask 提交时注入 Agent Profile 配置
  • agent-atoms.ts — 新增 agentSessionProfileMapAtom
  • settings-tab.ts — 新增 'agents' tab ID
  • main.tsx / index.ts / preload/index.ts / types/settings.ts — 启动初始化 + IPC bridge

审查情况

3 个 SubAgent 并行审查(主进程/渲染层/设置页 UI),共发现 4 Critical + 12 Warning + 6 Nit

  • QuickTask @agent 发起的会话,ModelSelector 未显示 agent 配置的模型
  • 会话内手动切换模型后,下次发消息被 agent 配置覆盖
  • profileId UUID 正则校验防路径穿越
  • symlink 目标 resolve() + startsWith() 防目录逃逸
  • pluginBuildLocks Set 防同 profile 并发重建竞态

测试结果

  • 全部 Critical 和 Warning 已修复,bun run typecheck 通过
  • 用户测试确认功能正常

引入 Agent Profile 作为独立全局实体,支持角色定义、模型配置、MCP/Skills 精确过滤。

核心功能:
- AgentProfile 数据模型与 CRUD(agents.json 全局存储)
- 基于 symlink 的 Skill 精确过滤(临时 plugin 目录 + 缓存复用)
- Profile 级 MCP 服务器精确加载(空数组 = 不使用)
- QuickTask(Option+Space)@ mention 选择 Agent,内联 mention 标签
- 会话级 Agent 配置注入(channel/model/thinking/effort/budget/turns/additionalPrompt)
- 配置优先级:会话输入 > Agent Profile > 全局默认
- 设置页 Agents Tab:emoji picker、chip 能力选择、折叠高级选项、骨架屏

Bug 修复:
- QuickTask @agent 发起的会话模型选择器未正确显示
- 会话内手动切换模型被 agent 配置覆盖

安全加固:
- profileId UUID 格式校验防路径穿越
- symlink 目标路径校验防目录逃逸
- 并发构建锁防止同 profile 竞态重建
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant